//登录弹出层
Ext.define('Logisticext.ui.LoginWindow', {
    extend: 'Ext.Window',
    config: {},
    title: '登录窗口',
    width: 400,
    modal: true,
    draggable: false,
    closable: false,
    esizable: false,
    bodyStyle: 'background:#fff',
    layout: {type: 'vbox', align: 'center'},
    items: [{
            xtype: 'form',
            itemId: 'loginForm',
            border: false,
            url: BASE_URL + '/identity/enter',
            fieldDefaults: {msgTarget: 'side', labelWidth: 75},
            bodyPadding: '5 5 0',
            width: 350,
            items: [
                {fieldLabel: '用户名', xtype: 'textfield', allowBlank: false,
                    name: 'userName', tooltip: '请输入用户名'},
                {fieldLabel: '密　码', xtype: 'textfield', name: 'password',
                    inputType: 'password', allowBlank: false, tooltip: '请输入密码'}]}],
    initComponent: function() {
        var _this = this;
        this.buttons = [
            {
                text: '登录',
                itemId: 'login',
                handler: function() {
                    _this
                            .getComponent('loginForm')
                            .submit(
                                    {
                                        method: 'POST',
                                        success: function(form, action) {
                                            top.location.href = BASE_URL + "/index.jsp";
                                        },
                                        failure: function(form, action) {
                                            switch (action.failureType) {
                                                case Ext.form.action.Action.CLIENT_INVALID:
                                                    Ext.Msg
                                                            .alert('Failure',
                                                                    'Form fields may not be submitted with invalid values');
                                                    break;
                                                case Ext.form.action.Action.CONNECT_FAILURE:
                                                    Ext.Msg.alert('Failure',
                                                            'Ajax communication failed');
                                                    break;
                                                case Ext.form.action.Action.SERVER_INVALID:
                                                    Ext.Msg.alert('Failure', action.result.msg);
                                            }
                                        }});
                }},
            {text: '忘记密码', itemId: 'forgot', handler: function() {
                    alert('mao');
                }}];
        this.callParent();
    }});